package com.asialjim.wechat.pojo.user;

import com.asialjim.wechat.utils.JsonUtils;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatUser ]</i></h2><strong>
 * <p> 微信用户实体
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/2/27   &nbsp;&nbsp; JDK 8
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "T_WECHAT_USER")
@JsonIgnoreProperties(ignoreUnknown = true)
public class WeChatUser implements Serializable {
    private static final long serialVersionUID = -206517971508746122L;

    @JsonProperty("openid")
    @TableId(type = IdType.INPUT)
    private String openId;

    @JsonProperty("nickname")
    private String nickName;

    private Integer subscribe;

    private Integer sex;

    private String language;

    private String city;

    private String province;

    private String country;

    @JsonProperty("headimgurl")
    private String headImgUrl;

    @JsonProperty("subscribe_time")
    private Long subscribeTime;

    @JsonProperty("unionid")
    private String unionId;

    private String remark;

    @JsonProperty("groupid")
    private Integer groupId;

    @JsonProperty("tagid_list")
    private List<Integer> tagIdList;

    @JsonProperty("subscribe_scene")
    private String subscribeScene;

    @JsonProperty("qr_scene")
    private Integer qrScene;

    @JsonProperty("qr_scene_str")
    private String qrSceneStr;

    private String subjectId;

    public String getTagIdList(){
        return JsonUtils.toJson(this.tagIdList);
    }
    public void setTagIdList(Object tagIdList){
        if (tagIdList instanceof List){
            this.tagIdList = (List)tagIdList;
        }
        if (tagIdList instanceof String ){
            this.tagIdList = JsonUtils.jsonToList((String)tagIdList,Integer.class);
        }
    }
}
